﻿using System.Web.SessionState;
using CommonBehaviors.Actions;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.Routines;
using Styx.TreeSharp;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using Action = Styx.TreeSharp.Action;

#region [Method] - Class Redundancy
using C = Ilusión.Rotation.Conditions;
using HkM = Ilusión.Core.Managers.Hotkey_Manager;
using SB = Ilusión.Core.Helpers.Spell_Book;
using TM = Ilusión.Core.Managers.Talent_Manager;
using U = Ilusión.Core.Unit;
using S = Ilusión.Core.Spell;
#endregion  

namespace Ilusión.Rotation

{
    class Rotation
    {
        private static LocalPlayer Me { get { return StyxWoW.Me; } }

  
        #region preCombatBuffing
        public static Composite preCombatBuffing()
        {
            return new PrioritySelector(
                new Decorator(ret => HkM.manualOn || !Me.IsAlive || Me.IsCasting || Me.IsChanneling || Me.Mounted || Me.OnTaxi, new ActionAlwaysSucceed())
                //actions.precombat=flask,type=warm_sun

                //actions.precombat+=/food,type=mogu_fish_stew

                //Power_word_fortitude,if=!aura.stamina.up
                //S.Buff(SB.PowerWordFortitude, ret => true

                //Inner_fire
                //S.Buff(SB.InnerFire, ret => true

                //Shadowform,if=!aura.shadowform
                //S.Buff(SB.Shadowform, ret => true

                //actions.precombat+=/snapshot_stats

                //actions.precombat+=/jade_serpent_potion
                );
        }  

        #endregion

        #region CombatBuffing
        public static Composite combatBuffing()
        {
            return new PrioritySelector(
                new Decorator(ret => HkM.manualOn || !Me.IsAlive || !Me.GotTarget, new ActionAlwaysSucceed())
                //Na
                );
        } 
        
        #endregion

        #region RotationSlector
        public static Composite rotationSelector()
{
    return new PrioritySelector(
        new Decorator(ret => HkM.manualOn || !Me.IsAlive || !Me.GotTarget, new ActionAlwaysSucceed()),
        new Switch<bool>(ret => HkM.aoeOn,
            new SwitchArgument<bool>(true,
                new PrioritySelector(
                //mindbender,if=talent.mindbender.enabled
                //S.Cast(SB.Mindbender, ret => true

                //shadowfiend,if=!talent.mindbender.enabled
                //S.Cast(SB.Shadowfiend, ret => true

                //power_infusion,if=talent.power_infusion.enabled
                //S.Cast(SB.PowerInfusion, ret => true

                //devouring_plague,if=shadow_orb=3&(cooldown.mind_blast.remains<1.5|target.health.pct<20&cooldown.shadow_word_death.remains<1.5)
                //S.Cast(SB.DevouringPlague, ret => U.isUnitValid(Unit, Range));

                //mind_flay_insanity,if=target.dot.devouring_plague_tick.ticks_remain=1,chain=1
                //S.Cast(SB.MindFlay, ret => U.isUnitValid(Unit, Range));

                //shadow_word_pain,cycle_targets=1,max_cycle_targets=5,if=miss_react&!ticking
                //S.Cast(SB.ShadowWordPain, ret => U.isUnitValid(Unit, Range));

                //vampiric_touch,cycle_targets=1,max_cycle_targets=5,if=remains<cast_time&miss_react
                //S.Cast(SB.VampiricTouch, ret => U.isUnitValid(Unit, Range));

                //shadow_word_pain,cycle_targets=1,max_cycle_targets=5,if=miss_react&ticks_remain<=1
                //S.Cast(SB.ShadowWordPain, ret => U.isUnitValid(Unit, Range));

                //vampiric_touch,cycle_targets=1,max_cycle_targets=5,if=remains<cast_time+tick_time&miss_react
                //S.Cast(SB.VampiricTouch, ret => U.isUnitValid(Unit, Range));

                //vampiric_embrace,if=shadow_orb=3&health.pct<=40
                //S.Cast(SB.VampiricEmbrace, ret => U.isUnitValid(Unit, Range));

                //devouring_plague,if=shadow_orb=3&ticks_remain<=1
                //S.Cast(SB.DevouringPlague, ret => U.isUnitValid(Unit, Range));

                //halo,if=talent.halo.enabled&target.distance<=30&target.distance>=17
                //S.Cast(SB.Halo, ret => U.isUnitValid(Unit, Range));

                //cascade_damage,if=talent.cascade.enabled&(active_enemies>1|(target.distance>=25&stat.mastery_rating<15000)|target.distance>=28)&target.distance<=40&target.distance>=11
                //S.Cast(SB.Cascade, ret => U.isUnitValid(Unit, Range));

                //divine_star,if=talent.divine_star.enabled&(active_enemies>1|stat.mastery_rating<3500)&target.distance<=24
                //S.Cast(SB.DivineStar, ret => U.isUnitValid(Unit, Range));

                //wait,sec=cooldown.shadow_word_death.remains,if=target.health.pct<20&cooldown.shadow_word_death.remains<0.5&active_enemies<=1
                //S.Cast(SB.ShadowWordDeath, ret => U.isUnitValid(Unit, Range));

                //wait,sec=cooldown.mind_blast.remains,if=cooldown.mind_blast.remains<0.5&active_enemies<=1
                //S.Cast(SB.MindBlast, ret => U.isUnitValid(Unit, Range));

                //mind_sear,chain=1,interrupt=1,if=active_enemies>=3
                //S.Cast(SB.MindSear, ret => U.isUnitValid(Unit, Range));

                //mind_flay,chain=1,interrupt=1
                //S.Cast(SB.MindFlay, ret => U.isUnitValid(Unit, Range));

                //shadow_word_death,moving=1
                //S.Cast(SB.ShadowWordDeath, ret => U.isUnitValid(Unit, Range));

                //mind_blast,moving=1,if=buff.divine_insight_shadow.react&cooldown_react
                //S.Cast(SB.MindBlast, ret => U.isUnitValid(Unit, Range));

                //divine_star,moving=1,if=talent.divine_star.enabled&target.distance<=28
                //S.Cast(SB.DivineStar, ret => U.isUnitValid(Unit, Range));

                //cascade_damage,moving=1,if=talent.cascade.enabled&target.distance<=40
                //S.Cast(SB.Cascade, ret => U.isUnitValid(Unit, Range));

                //shadow_word_pain,moving=1
                //S.Cast(SB.ShadowWordPain, ret => U.isUnitValid(Unit, Range));

                //dispersion
                //S.Cast(SB.Dispersion, ret => true
                )),
            new SwitchArgument<bool>(false,
                new PrioritySelector(
                //mindbender,if=talent.mindbender.enabled
                //shadowfiend,if=!talent.mindbender.enabled
                //power_infusion,if=talent.power_infusion.enabled
                //shadow_word_death,if=buff.shadow_word_death_reset_cooldown.stack=1&active_enemies<=5
                //devouring_plague,if=shadow_orb=3&(cooldown.mind_blast.remains<1.5|target.health.pct<20&cooldown.shadow_word_death.remains<1.5)
                //mind_blast,if=active_enemies<=5&cooldown_react
                //shadow_word_death,if=buff.shadow_word_death_reset_cooldown.stack=0&active_enemies<=5
                //mind_flay_insanity,if=target.dot.devouring_plague_tick.ticks_remain=1,chain=1
                //mind_flay_insanity,interrupt=1,chain=1,if=active_enemies<=5
                //vampiric_embrace,if=shadow_orb=3&health.pct<=40
                //devouring_plague,if=shadow_orb=3&ticks_remain<=1
                //mind_spike,if=active_enemies<=5&buff.surge_of_darkness.react=2
                //halo,if=talent.halo.enabled&target.distance<=30&target.distance>=17
                //cascade_damage,if=talent.cascade.enabled&(active_enemies>1|(target.distance>=25&stat.mastery_rating<15000)|target.distance>=28)&target.distance<=40&target.distance>=11
                //divine_star,if=talent.divine_star.enabled&(active_enemies>1|stat.mastery_rating<3500)&target.distance<=24
                //wait,sec=cooldown.shadow_word_death.remains,if=target.health.pct<20&cooldown.shadow_word_death.remains<0.5&active_enemies<=1
                //wait,sec=cooldown.mind_blast.remains,if=cooldown.mind_blast.remains<0.5&active_enemies<=1
                //mind_spike,if=buff.surge_of_darkness.react&active_enemies<=5
                //mind_flay,chain=1,interrupt=1
                //shadow_word_death,moving=1
                //mind_blast,moving=1,if=buff.divine_insight_shadow.react&cooldown_react
                //divine_star,moving=1,if=talent.divine_star.enabled&target.distance<=28
                //cascade_damage,moving=1,if=talent.cascade.enabled&target.distance<=40
                //shadow_word_pain,moving=1
                //dispersion
                ))));
}
       #endregion
    }
}
